import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		char[] ans = sc.nextLine().toCharArray();
		String input;
		char[] ques;
		int a, b;
		String output;
		
		while(sc.hasNext()) {
			input = sc.nextLine();
			if(input.equals("0000"))
				{ System.exit(0); }
			
			ques = input.toCharArray();
			
			a = 0;
			b = 0;
			
			for(int i = 0; i < 4; i++) {
				if(ques[i] == ans[i]) {
					a++;
				} else {
					for(int j = 0; j < 4; j++) {
						if(j == i)
							{ continue; }
						
						if(ques[i] == ans[j])
							{ b++; }
					}
				}
			}
			
			output = (Integer.toString(a) + "A" + Integer.toString(b) + "B");
			
			System.out.println(output);
		}
	}
}